/*
 * GameMap.fx
 *
 * Created on 02.12.2009, 12:41:00
 */

package org.zhgames.zhciv.client.gui.scenes;

import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import org.zhgames.zhciv.util.Util;
import org.zhgames.zhciv.client.gui.*;
import org.zhgames.zhciv.common.model.*;

/**
 * @author Vitaliy_Turilkin
 */

public class GameMap extends CustomNode{
    //test options
    def lw:Number = GameMapManager.CELL_WIDTH;
    def lh:Number = GameMapManager.CELL_HEIGHT;
    def mapw = GameMapManager.FIELD_WIDTH;
    def maph = GameMapManager.FIELD_HEIGHT;

    def gmap:Group = Group{
        content:[
            for(y in [0..maph step lh]){
                var points:Number[] = [];
                var yp:Boolean = not Util.isEven(y/lh); // y position

                for(x in [0..mapw step lw]){
                    //if(x != 0 and y != 0){
                    if(yp){
                        insert [x, y+lh] into points;
                        yp = false;
                    }else{
                        insert [x, y] into points;
                        yp = true;
                    }
                    Polyline {
                        points : points
                        strokeWidth: 0.5
                        stroke: Color.BLACK
                    }
                    //}
                }
            }
        ]
    }

    override function create():Node {
        def group = Group {
            content:[
                BorderScrollView{
                    width: bind scene.width
                    height: bind scene.height - 200
                    fill: Color.GREEN
                    node: gmap
                }
            ]
        };
        return group;
    }
}